// Copyright 2024 Administrator
// 
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// 
//     http://www.apache.org/licenses/LICENSE-2.0
// 
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

import { Transform } from "class-transformer";
import { IsBoolean, IsEnum, IsNumber, IsOptional, IsString } from "class-validator";
import { AudioRateEnum } from "src/common/enums/audio.enum";
import { UploadFile } from "../../song/dto/create-song.dto";

export class RateFileInfoDto {
    @IsOptional()
    @IsNumber({ allowNaN: false }, { message: "音质id格式不正确" })
    id?: number;

    //音频质量
    @IsEnum(AudioRateEnum, { message: "音频质量格式不正确" })
    rate: AudioRateEnum;

    //资源的size大小
    @IsOptional()
    @Transform(v => +v)
    @IsNumber({ allowNaN: false }, { message: "音质size格式不正确" })
    size: number;

    //资源的格式
    @IsString({ message: "音频格式不正确" })
    format: string;

    //歌曲时长
    @IsNumber({ allowNaN: false }, { message: "音频时长不正确" })
    duration: number;

    //是否是完整的
    @IsBoolean({ message: "是否是试听必传" })
    isFull: boolean;

    @IsOptional()
    @IsNumber({ allowNaN: false }, { message: "音频时长不正确" })
    percentage?: number;

    @IsNumber({ allowNaN: false }, { message: "音频上传进度不正确" })
    uploadProgress: number;

    //文件
    @IsOptional()
    file?: UploadFile;

    @IsOptional()
    blob?: Blob;

    @IsOptional()
    @IsString({ message: "音频mimetye不正确" })
    mimeType?: string;
    //操作状态
    @IsOptional()
    status?: any;

    //资源名称
    @IsOptional()
    @IsString({ message: "音频文件名称不正确" })
    name?: string;

    //上传完成返回的文件id
    @IsString({ message: "上传完成返回的文件id格式不正确" })
    fileId: string;
}